package com.dnw.shyfunny;

import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import com.dnw.base.BaseActivity;
import com.dnw.modle.Result;
import com.dnw.presenter.OpinionPresenter;
import com.dnw.util.UIUtils;
import com.dnw.view.IOpinionView;

import butterknife.Bind;
import butterknife.OnClick;
import flyn.Eyes;

/**
 * Created by yangyu on 2017/11/16.
 * 意见反馈
 */

public class OpinionActivity extends BaseActivity<OpinionPresenter> implements IOpinionView {
    @Bind(R.id.tv_author)
    TextView tvAuthor;

    @Bind(R.id.bt_opinion)
    Button btOpinion;

    @Bind(R.id.et_opinion)
    EditText etOpinion;

    @Override
    public void initView() {
        Eyes.setStatusBarColor(this, UIUtils.getColor(R.color.a));
    }

    @Override
    public void initData() {
        tvAuthor.setText(getResources().getString(R.string.side_column_opinion));
    }

    @Override
    protected OpinionPresenter createPresenter() {
        return new OpinionPresenter(this);
    }

    @Override
    protected int provideContentViewId() {
        return R.layout.activity_opinion;
    }

    @OnClick({R.id.tv_back, R.id.bt_opinion})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.tv_back:
                finish();
                break;
            case R.id.bt_opinion:
                mPresenter.getOpinionResult(etOpinion.getText().toString());
                break;
        }
    }

    @Override
    public void onGetOpinionSuccess(Result result) {
        if (result.code == 0) {
            UIUtils.showToast("提交成功，感谢您的反馈！");
            finish();
        } else {
            UIUtils.showToast(result.msg);
        }
    }

    @Override
    public void onError() {

    }
}